/**
 * 
 */
package hihocoder;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class MSFT {

	static int result;
	static HashMap<String, Boolean> ssHashMap;
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		scanner.nextLine();
		for (int i = 0; i < N; i++) {
			result=Integer.MAX_VALUE;
			ssHashMap=new HashMap<>();
			String S=scanner.nextLine();
			String T=scanner.nextLine();
			ssHashMap.put(S, false);
			getRes(S,T,0,0);
			System.out.println(result);
		}
	}

	private static void getRes(String s, String t, int i,int swapCount) {
		if(swapCount>=result){
			return;
		}
		if(i>=s.length()){
			ssHashMap.put(s,true);
			if(s.equals(t)){
				if(swapCount<result){
					System.out.println("update  "+swapCount);
					result=swapCount;
				}
			}
			return;
		}
		if(s.charAt(i)==t.charAt(i)){
			i++;
			getRes(s, t, i+1, swapCount);
		}else {
			char curCh=s.charAt(i);
			for (int j = 0; j < t.length(); j++) {
				if(t.charAt(j)==curCh){//新位置
					//交换位置得到新字符串，如果字符串没有出现过，则加入带访问的hashmap且递归
					System.out.println(i+" "+j);
					
					String newS=swapChars(s, i, j);
					System.out.println(s+"  交换后 \n"+newS+" 目标\n"+t);
					if(!ssHashMap.containsKey(newS)){
						ssHashMap.put(newS, false);
						getRes(newS, t, i+1, swapCount+1);
					}
				}
			}
		}
	}
	
	private static String swapChars(String str, int lIdx, int rIdx) {
	    StringBuilder sb = new StringBuilder(str);
	    char l = sb.charAt(lIdx), r = sb.charAt(rIdx);
	    sb.setCharAt(lIdx, r);
	    sb.setCharAt(rIdx, l);
	    return sb.toString();
	  }
}
